package cn.edu.sgu.www.mhxysy.observer.impl;

import cn.edu.sgu.www.mhxysy.function.computer.score.impl.RoleScoreComputer;
import cn.edu.sgu.www.mhxysy.observer.Observer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 具体观察者-角色评分观察者
 * @author 沐雨橙风ιε
 * @version 1.0
 */
@Slf4j
@Component
public class RoleScoreObserver implements Observer {

    private final RoleScoreComputer roleScoreComputer;

    public RoleScoreObserver(RoleScoreComputer roleScoreComputer) {
        this.roleScoreComputer = roleScoreComputer;
    }

    @Override
    public void update(Object message) {
        String roleId = (String) message;

        Integer score = roleScoreComputer.compute(roleId);

        log.debug("角色评分变化：{}", score);
    }

}